using System.IO;
using HardMock;
using Xunit;

namespace AcceptanceTests
{
    public class AutoPropertyFeature
    {
        [Fact]
        public void Simulate_autoproperty_behavior()
        {
            Simulate_autoproperty_behavior(new StateFullHardMock());
            Simulate_autoproperty_behavior(new StateLessHardMock());
        }

        private static void Simulate_autoproperty_behavior(IHardMock hardMock)
        {
            var recorder = hardMock.BuildRecorderOver<_MUODate>(new MUODate());

            SetDifferentValueToProperty(recorder);

            using (var stream = new MemoryStream())
            {
                recorder.Snapshot(stream);
                var replayer = hardMock.BuildMockFrom<_MUODate>(stream);

                SetDifferentValueToProperty(replayer);
            }
        }

        private static void SetDifferentValueToProperty(_MUODate recorder)
        {
            recorder.AutoProperty = "toto";

            Assert.Equal("toto", recorder.AutoProperty);

            recorder.AutoProperty = "tutu";

            Assert.Equal("tutu", recorder.AutoProperty);
        }
    }
}